<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>07 js数据类型转化</title>
</head>

<body>


    <script>
        var a = 10; //Number
        var b = '10'; //String
        console.log('==', a == b); //true
        console.log('===', a === b); //false

        var a = '100';
        console.log('b:', b, typeof b);
        var b = a / 1;
        console.log('b:', b, typeof b);

        var c = '100';
        var d = 100;
        console.log('c:', c, typeof c, '黑色 字符串')
        console.log('d:', d, typeof d, '蓝色 数值')

        var e = '100';
        var f = 100;
        console.log('e + f :', e + f); //100100, 拼接符

        var e = '100';
        var g = '50';
        console.log('e - g :', e - g); //隐式转换

        console.log('------------------------------')
            //常见面试题  坑！！！
        console.log("1 + 'true':", 1 + 'true');
        console.log('1 + true:', 1 + true);
        console.log('1 + undefined:', 1 + undefined);
        console.log('------------------------------')


        //toString()  Number()  parseInt()  parseFloat()
        var a = 100;
        var b = a.toString();
        console.log(b, typeof b);

        var b = Number('100');
        console.log(b, typeof b);

        console.log(parseInt('10')); //10
        console.log(parseInt('10s')); //10
        console.log(parseInt('10s1111111')); //10
        console.log(parseInt('10.1111111')); //10
        console.log(parseInt('aa10.1111111')); //NaN
        console.log(isNaN('aa10.111111'));
    </script>
</body>

</html>